package test;

public class FindChar {
	public static void main(String[] args) {
		System.out.println("请输入一个字符串,以回车结束:");
		StringBuffer sbf = new StringBuffer();
		int ch;
		try {
			while ((ch = System.in.read()) != '\n') {
				sbf.append((char) ch);
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		int charCount = 0;
		int numCount = 0;
		for (int i = 0; i < sbf.length(); i++) {
			char c = sbf.charAt(i);
			if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z'))
				charCount++;
			if ((c - 48) >= 0 && (c - 48) <= 9)
				numCount++;
		}
		System.out.println("该字符串中字母为" + charCount + "个，数字为" + numCount + "个");
	}
}